<?php

session_start();

function chaineAleatoire(int $taille=16) {
	
	$base='ABCDEFGHKLMNOPQRSTWXYZabcdefghjkmnpqrstwxyz123456789';
	$max=strlen($base)-1;
	$result='';
	while (strlen($result)<$taille+1) $result.=$base{mt_rand(0,$max)};
	
	return $result;
}

if (!isset($_SESSION['init']))
{
    session_regenerate_id();
    $_SESSION['init'] = true;
    $_SESSION['ALEATOIRE']=chaineAleatoire(16);
    $_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT'].$_SESSION['ALEATOIRE']);
}

if ($_SESSION['HTTP_USER_AGENT'] != md5($_SERVER['HTTP_USER_AGENT'].$_SESSION['ALEATOIRE']))
{
  exit;
}


?>

